const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const TerserJSPlugin = require("optimize-css-assets-webpack-plugin")
const OptimizeCSSAssetsPlugin = require("terser-webpack-plugin")

module.exports = {
    // mode: 'development',
    mode: 'production',
    entry: "./main.js", //打包入口
    output: {
        path: __dirname,
        filename: 'bundle.js'
    },
    optimization: {
        minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
    },
    plugins: [
        new MiniCssExtractPlugin({
            filename: 'css/[name].css' //css打包输出出口及文件名称
        })
    ],
    module: {
        rules: [
            {
                test: /\.css$/,
                use:[
                    MiniCssExtractPlugin.loader,
                    "style-loader",
                    "css-loader"
                ]
            },
            {
                test: /\.scss$/,
                use: [
                    MiniCssExtractPlugin.loader,
                    'css-loader',
                    'sass-loader'
                ]
            }
        ]
    }
}